#include<iostream>
using namespace std;
#include<vector>
class Solution {
public:
    int rob(vector<int>& nums) {
        int n = nums.size();
        int arr[2];
        arr[0] = 0;
        arr[1] = nums[0];
        for (int i = 1; i < nums.size(); ++i) {
            int sum = max(arr[0] + nums[i], arr[1]);
            arr[0] = arr[1];
            arr[1] = sum;
        }
        return arr[1];
    }
};